import { WatchSource } from "vue";
import { GameAction, GameData } from "@/types/game/index";
import { Player } from "./player";
import eventList from "@/game/event-list";
import eventCreatorList from "@/game/event-creator";
export type GameEventManager = {
    addEvent: (gameEventSource: GameEvent) => void;
    addEventUseCreator: (name: string, ...args: any[]) => void;
    removeEvent: (picker: GameEvent | ((event: GameEvent) => boolean)) => void;
    eventList: typeof eventList
    eventCreatorList: typeof eventCreatorList
}
export interface GameEvent {
    name: string;
    data: {
        [key: string]: any
    }
    action?: (eventData: GameEvent['data'], gameData: GameData, gameAction: GameAction, eventManager: GameEventManager) => Promise<void>;
    actionDelay?: 'afterListener'
}
export interface GamePlayerEvent extends GameEvent {
    data: {
        player: Player,
        [key: string]: any
    }
}

export interface GameEventListener {
    name?: string;
    filter?: (event: GameEvent, gameData: GameData) => boolean | undefined;
    callback: (event: GameEvent, gameData: GameData, gameAction: GameAction, eventManager: GameEventManager) => Promise<void>;
    order?: number;
}
export interface GameEventTrigger {
    source: WatchSource;
    filter?: (newValue: any, oldValue: any, gameData: GameData) => boolean | undefined;
    event: GameEvent;
}